package com.yfuxdeer.youchat.utils;

import com.yfuxdeer.youchat.pojo.FragmentItem;
import com.yfuxdeer.youchat.pojo.FriendItem;
import com.yfuxdeer.youchat.pojo.MessageItem;

import java.util.ArrayList;
import java.util.List;

public class ConvertUtil {
    public static List<FragmentItem> MessageItem2FragmentItem(List<MessageItem> messageItemList) {
        List<FragmentItem> fragmentItemList = new ArrayList<>();
        if (messageItemList == null)
            return fragmentItemList;
        for (MessageItem messageItem : messageItemList) {
            FragmentItem fragmentItem = new FragmentItem();
            fragmentItem.setHead_id(messageItem.getFriend_id());
            fragmentItem.setTitle(messageItem.getRemark());
            fragmentItem.setSub_title(messageItem.getLastMessage());
            fragmentItem.setAddition(DateUtil.getDate(messageItem.getTime()));
            fragmentItemList.add(fragmentItem);
        }
        return fragmentItemList;
    }

    public static List<FragmentItem> FriendItem2FragmentItem(List<FriendItem> friendItemList) {
        List<FragmentItem> fragmentItemList = new ArrayList<>();
        if (friendItemList == null)
            return fragmentItemList;
        for (FriendItem friendItem : friendItemList) {
            FragmentItem fragmentItem = new FragmentItem();
            fragmentItem.setHead_id(friendItem.getFriend_id());
            fragmentItem.setTitle(friendItem.getRemark());
            fragmentItem.setSub_title(friendItem.getFigure());
            fragmentItem.setAddition(friendItem.getAddition());
            fragmentItemList.add(fragmentItem);
        }
        return fragmentItemList;
    }
}
